<template>
  <el-table :data="tableData" height="433" border style="width: 100%">
    <el-table-column prop="reciever" label="收货人" width="180">
    </el-table-column>
        <el-table-column prop="recieverPhone" label="收货人手机号">
    </el-table-column>
    <el-table-column prop="recieverAddress" label="收货地址" width="300">
    </el-table-column>
    <el-table-column prop="userCode" label="账户"> </el-table-column>
    <el-table-column label="操作">
      <!-- <router-link to="/personalDetail">查看</router-link> -->
    </el-table-column>
  </el-table>
</template>

<script>
export default {
  data() {
    return {
      userCode:"",
      tableData: [{}],
    };
  },
  methods: {
    searchUser() {
      this.findUser();
    },
    findUser() {
      let userCode=JSON.parse(sessionStorage.getItem("userCode"));
      this.userCode=userCode.userCode
      this.axios.get(`http://localhost:8081/address/showList?userCode=${this.userCode}`).then((result) => {
        console.log(result.data.object);
        this.tableData = result.data.object;
      });
    },
  },
  created() {
    this.findUser();
  },

  watch: {
    $route: {
      handler(to) {
        if (to.path == "/personal") {
          this.userCode
          this.findUser();
        }
      },
    },
  },
};
</script>